/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jpIngresosAjuste.java
 *
 * Created on 21-sep-2010, 15:53:46
 */

package Inventario;

import administracion.BeanBinding.TblBeanBindingDetalleIngreso;
import administracion.BeanBinding.TblBeanBindingDetalleUbicacion;
import administracion.delegate.GestionPedidosDelegate;
import administracion.helper.Listas;
import administracion.helper.Utiles_Fecha;
import administracion.helper.Utiles_MensajesDialogo;
import administracion.helper.Utiles_Tabla;
import administracion.helper.VerificarDatos;
import administracion.propiedades.Propiedades;
import com.jidesoft.hints.ListDataIntelliHints;
import java.awt.event.KeyEvent;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.text.MaskFormatter;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.view.JasperViewer;
import org.jdesktop.beansbinding.AutoBinding;
import org.jdesktop.beansbinding.BindingGroup;
import org.jdesktop.beansbinding.ELProperty;
import org.jdesktop.swingbinding.JTableBinding;
import org.jdesktop.swingbinding.SwingBindings;
import suministros.ejb30.TO.AlmacenTO;
import suministros.ejb30.TO.CentroCostoTO;
import suministros.ejb30.TO.EmpresaTO;
import suministros.ejb30.TO.ProyectoTO;
import suministros.ejb30.TO.SubAlmacenTO;
import suministros.ejb30.TO.TipoTO;
import suministros.ejb30.TO.UnidadOrganizativaTO;
import suministros.ejb30.TO.ZonaTO;
import suministros.ejb30.entity.CentroCosto;
import suministros.ejb30.entity.DetalleMovimiento;
import suministros.ejb30.entity.DetalleMovimientoPK;
import suministros.ejb30.entity.Empresa;
import suministros.ejb30.entity.Movimiento;
import suministros.ejb30.entity.Parametros;
import suministros.ejb30.entity.Proyecto;
import suministros.ejb30.entity.Suministros;
import suministros.ejb30.entity.UnidadOrganizativa;
import suministros.ejb30.helper.Utiles_Convertir;

/**
 *
 * @author Diana
 */
public class jpIngresosAjuste extends javax.swing.JDialog {

    List<DetalleMovimiento> detallesIngreso= new ArrayList<DetalleMovimiento>();
    String codIngreso=null;
    private List<TblBeanBindingDetalleIngreso>  detallesdevolucion= new ArrayList<TblBeanBindingDetalleIngreso>();
    jifIngresoAjusteInventario padre;
    private MaskFormatter mascaraFechaIngreso;
    List listaTipos = null;
    List listaTiposIngreso = null;
    EmpresaTO empresa;
    private JTableBinding jTableBinding;
    private BindingGroup bindingGroup;




    /** Creates new form jpIngresosAjuste */
    public jpIngresosAjuste(jifIngresoAjusteInventario padre,java.awt.Frame parent, boolean modal, EmpresaTO empresa, TblBeanBindingDetalleIngreso detallesIngreso) {
        super(parent, modal);   
        construirMascaras();
        initComponents();
        pack();
        this.padre=padre;
        llenarComboTipoMovimiento();
        llenarComboTipoIngreso();
        this.empresa=empresa;
        this.jLabel1.setText(empresa.getRazon());
        this.detallesdevolucion.add(detallesIngreso);
        actualizaTablaDetalle();
      


    }
     private void actualizaTablaDetalle() {
        this.bindingGroup = new BindingGroup();
        this.jTableBinding = SwingBindings.createJTableBinding(AutoBinding.UpdateStrategy.READ, this.detallesdevolucion, this.jtDetalleSuministro);

        JTableBinding.ColumnBinding columnBinding0 = this.jTableBinding.addColumnBinding(ELProperty.create("${idsuministro}"));

        columnBinding0.setColumnName("ID Suministro");
        columnBinding0.setColumnClass(String.class);
        columnBinding0.setEditable(false);

        JTableBinding.ColumnBinding columnBinding1 = this.jTableBinding.addColumnBinding(ELProperty.create("${nomsuministro}"));

        columnBinding1.setColumnName("Suministro");
        columnBinding1.setColumnClass(String.class);
        columnBinding1.setEditable(false);

        JTableBinding.ColumnBinding columnBinding2 = this.jTableBinding.addColumnBinding(ELProperty.create("${cantidadInventario}"));

        columnBinding2.setColumnName("Cantidad");
        columnBinding2.setColumnClass(BigDecimal.class);
        columnBinding2.setEditable(true);

        JTableBinding.ColumnBinding columnBinding3 = this.jTableBinding.addColumnBinding(ELProperty.create("${precio}"));

        columnBinding3.setColumnName("Precio");
        columnBinding3.setColumnClass(BigDecimal.class);
        columnBinding3.setEditable(false);



        this.bindingGroup.addBinding(this.jTableBinding);
        this.bindingGroup.bind();
        int[] porcentajes= {15,65,15,15};
         try {
           Utiles_Tabla.definirAnchoColumnasJTable(jtDetalleSuministro, porcentajes);
          // MiTablePrint.autoSizeTableColumns(jtDetalleSuministro);
        } catch (Exception ex) {
            Logger.getLogger(jpIngresosAjuste.class.getName()).log(Level.SEVERE, null, ex);
        }

      }
      

     private void llenarComboTipoMovimiento() {

        List listaTipos_cbo = this.cboBeanBindingTipo2.getLista();
        listaTipos_cbo.clear();
        try
        {
         listaTipos = Listas.getTipo_porTabla("tipo_Movimiento");

        } catch (Exception ex) {
          Utiles_MensajesDialogo.mensajeAlerta("Error al obtener tipos documentos\n" + ex.getMessage());
          ex.printStackTrace();
          Logger.getLogger(jpIngresosAjuste.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
      private void llenarComboTipoIngreso() {
        List listaTipos_cbo1 = this.cboBeanBindingTipo1.getLista();
        listaTipos_cbo1.clear();
        try
        {
          listaTiposIngreso = Listas.getTipo_porTabla("tipo_ingreso");
          this.cboBeanBindingTipo1.setLista(listaTiposIngreso);

        } catch (Exception ex) {
          Utiles_MensajesDialogo.mensajeAlerta("Error al obtener Ingresos\n" + ex.getMessage());
          ex.printStackTrace();
          Logger.getLogger(jpIngresosAjuste.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
     private void construirMascaras() {
    try {
      this.mascaraFechaIngreso = new MaskFormatter("##/##/####");
      //this.mascaraCodigo= new MaskFormatter("##########");
    } catch (ParseException ex) {
      Logger.getLogger(jpIngresosAjuste.class.getName()).log(Level.SEVERE, null, ex);
      ex.printStackTrace();
    }
  }

    public void GenerarReporte(String codigo){
        if(codigo!=null){
        JasperViewer jv = null;
        JasperPrint jp = null;
        Map parametros = new HashMap();
        parametros.put("idMovimiento", codigo);
        try {
            jp=GestionPedidosDelegate.getInstance().generarReporteIngreso("NotaIngresoFLP.jasper", parametros);
            jv = new JasperViewer(jp, false);
            jv.setExtendedState(javax.swing.JFrame.MAXIMIZED_BOTH);
            jv.setVisible(true);
        }catch (Exception e) {
            Utiles_MensajesDialogo.mensajeError("No se pudo realizar la transaccion");
        }
        }
       


  }
 private void limpiar(){      
        this.detallesdevolucion.clear();
        this.pack();

    }
 public String RegistrarMovimiento() throws Exception{
        String codigo=null;
        BigDecimal cantidadRequerida= BigDecimal.valueOf(Double.valueOf(new Float(this.jtDetalleSuministro.getValueAt(0, 2).toString()).toString()).doubleValue());
        List detalle_ingresoDev = new ArrayList(1);
        Parametros param = Listas.getParametrosID("SU1");
        String ano = param.getParam1();
        String mes = param.getParam2();

        Date fecha = new Date(VerificarDatos.verificaFecha(this.jtfFecha.getText()).getTime());
        Utiles_Fecha utf = new Utiles_Fecha(fecha);
        if ((!utf.getAnio().equalsIgnoreCase(ano)) || (!utf.getMes().equalsIgnoreCase(mes))) {
        Utiles_MensajesDialogo.mensajeAlerta("La fecha debe coincidir con el mes actual: " + ano + " - " + mes);
        }
        else{
        Movimiento mov= new Movimiento();
        mov.setNumero(this.jtfNumero.getText());
        mov.setSerie(this.jtfSerie.getText());
        mov.setAnio(ano);
        mov.setFecha(fecha);
        mov.setMes(mes);
        mov.setTipoIngreso(Utiles_Convertir.convertirToTipo_TipoTO((TipoTO)this.listaTiposIngreso.get(3)));
        mov.setTipoMovimiento(Utiles_Convertir.convertirToTipo_TipoTO((TipoTO)this.listaTipos.get(0)));
        mov.setEmpresa(Utiles_Convertir.convertirToEmpresa_EmpresaTO(this.empresa));
        mov.setObservacion(this.jtaObservacion.getText());
        int correlativo=1;
         String centro_costos=null;
         String unidad_organica=null;
         String cod_presupuestal=null;
         String cod_proyecto=null;
         String cod_inversion=null;
         String ctacble=null;
        for (TblBeanBindingDetalleIngreso deta : this.detallesdevolucion) {

          DetalleMovimiento detall = new DetalleMovimiento();
          DetalleMovimientoPK detallepk= new DetalleMovimientoPK(correlativo, "");
          detall.setDetalleMovimientoPK(detallepk);
          detall.setCantidad(cantidadRequerida);
          detall.setCcosto(centro_costos);
          detall.setCodInv(cod_inversion);
          detall.setCodPresupuestal(cod_presupuestal);
          detall.setFecha(fecha);
          detall.setIdProyecto(cod_proyecto);
          detall.setIdSuministro(new Suministros(deta.getIdsuministro()));
          detall.setId_unidad_organica(unidad_organica);
          detall.setPrecio(deta.getPrecio());
          detall.setTipoMovimiento(Utiles_Convertir.convertirToTipo_TipoTO((TipoTO)this.listaTipos.get(0)));
          detall.setValor((detall.getCantidad().multiply(detall.getPrecio())).setScale(5, RoundingMode.HALF_UP));
          detall.setEstado_ubicacion(new Integer(0));
          correlativo++;
          detalle_ingresoDev.add(detall);
          }

          codigo=GestionPedidosDelegate.getInstance().insertarNotaIngresoInventario(Propiedades.getUsuario(),Propiedades.getMac(),mov, detalle_ingresoDev, Listas.retornaInventario().getCodigo());

        }
        return codigo;

        }

  
   public static java.sql.Timestamp verificaFecha(String fecha)throws Exception{
        java.sql.Timestamp fecharegreso=null;
        fecharegreso=java.sql.Timestamp.valueOf(fecha);
        return fecharegreso;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        cboBeanBindingTipo1 = new administracion.BeanBinding.CboBeanBindingTipo();
        cboBeanBindingTipo2 = new administracion.BeanBinding.CboBeanBindingTipo();
        jButton3 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jtDetalleSuministro = new javax.swing.JTable();
        this.jtDetalleSuministro.getTableHeader().setReorderingAllowed(false) ;
        jbtAceptar = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jtfFecha = new javax.swing.JFormattedTextField(this.mascaraFechaIngreso);
        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtaObservacion = new javax.swing.JTextArea();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jtfSerie = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jtfNumero = new javax.swing.JTextField();

        jButton3.setFont(new java.awt.Font("Arial", 1, 12));
        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/view_text.png"))); // NOI18N
        jButton3.setMnemonic('V');
        jButton3.setText("VER NOTA INGRESO");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "DETALLE INGRESO", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 255))); // NOI18N

        jtDetalleSuministro.setFont(new java.awt.Font("Arial", 0, 12));
        jtDetalleSuministro.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "CODIGO", "DENOMINACION", "CANTIDAD", "PRECIO UNITARIO"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane2.setViewportView(jtDetalleSuministro);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 581, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(17, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jbtAceptar.setFont(new java.awt.Font("Arial", 1, 12));
        jbtAceptar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/button_ok.png"))); // NOI18N
        jbtAceptar.setMnemonic('A');
        jbtAceptar.setText("ACEPTAR");
        jbtAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtAceptarActionPerformed(evt);
            }
        });

        jButton2.setFont(new java.awt.Font("Arial", 1, 12));
        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/button_cancel.png"))); // NOI18N
        jButton2.setMnemonic('C');
        jButton2.setText("CERRAR");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "DATOS DE UBICACION", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 11), new java.awt.Color(0, 0, 255))); // NOI18N

        jLabel7.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel7.setText("Nº DOCUMENTO:");

        jLabel17.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel17.setText("EMPRESA");

        jLabel6.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel6.setText("FECHA:");

        jtfFecha.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfFechaKeyPressed(evt);
            }
        });

        jLabel1.setText("jLabel1");

        jtaObservacion.setColumns(20);
        jtaObservacion.setRows(5);
        jScrollPane1.setViewportView(jtaObservacion);

        jLabel3.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel3.setText("OBSERVACION:");

        jLabel4.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel4.setText("SERIE");

        jLabel5.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel5.setText("NUMERO");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel7)
                    .addComponent(jLabel17)
                    .addComponent(jLabel6)
                    .addComponent(jLabel3))
                .addGap(23, 23, 23)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtfSerie, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtfNumero, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 458, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtfFecha, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(15, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(1, 1, 1)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel17))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jLabel4)
                    .addComponent(jtfSerie, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(jtfNumero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jtfFecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addContainerGap(13, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(44, Short.MAX_VALUE)
                .addComponent(jbtAceptar, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(10, 10, 10)
                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(10, 10, 10)
                .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(46, 46, 46))
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jbtAceptar, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jtfFechaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfFechaKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jtaObservacion.requestFocus();
        }
}//GEN-LAST:event_jtfFechaKeyPressed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        if(codIngreso!=null){
            GenerarReporte(codIngreso);
        } else{
            Utiles_MensajesDialogo.mensajeFracaso("No se ha seleccionado una nota  de ingreso");

        }
}//GEN-LAST:event_jButton3ActionPerformed

    private void jbtAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtAceptarActionPerformed
 
                    try {
                        codIngreso=null;
                        codIngreso= this.RegistrarMovimiento();
                        Utiles_MensajesDialogo.mensajeExito();
                        this.limpiar();
                        GenerarReporte(codIngreso);
                    } catch (Exception ex) {
                        Logger.getLogger(jpIngresosAjuste.class.getName()).log(Level.SEVERE, null, ex);
                        Utiles_MensajesDialogo.mensajeFracaso("No se pudo registrar la nota de ingreso");
                    }
 
    }//GEN-LAST:event_jbtAceptarActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        int res = javax.swing.JOptionPane.showConfirmDialog( this,"Esta seguro de salir?",
                "Confirmar",javax.swing.JOptionPane.YES_NO_OPTION );
        if(res==javax.swing.JOptionPane.YES_OPTION){
            dispose();
        }
}//GEN-LAST:event_jButton2ActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private administracion.BeanBinding.CboBeanBindingTipo cboBeanBindingTipo1;
    private administracion.BeanBinding.CboBeanBindingTipo cboBeanBindingTipo2;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JButton jbtAceptar;
    private javax.swing.JTable jtDetalleSuministro;
    private javax.swing.JTextArea jtaObservacion;
    private javax.swing.JFormattedTextField jtfFecha;
    private javax.swing.JTextField jtfNumero;
    private javax.swing.JTextField jtfSerie;
    // End of variables declaration//GEN-END:variables

}
